import { resolve } from 'path'
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
import vue from '@vitejs/plugin-vue'

export default defineConfig({
  main: {
    plugins: [externalizeDepsPlugin()]
  },
  preload: {
    plugins: [externalizeDepsPlugin()]
  },
  renderer: {
    resolve: {
      alias: {
        '@': resolve('src/renderer/src')
      }
      //   'electron-store': { type: 'cjs' }
    },
    plugins: [vue()]
  },
  //   pluginOptions: {
  //     electronBuilder: {
  //       nodeIntegration: true
  //     }
  //   }
  server: {
    port: 5173,
    proxy: {
      '/api': {
        target: 'http://localhost:3001/',
        // target: 'http://127.0.0.1:3001/',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      }
    }
  }
})
